<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
</head>

<body>
    <div id="app">
        c的输入框<input type="text" v-model="c">
        a的输入框<input type="text" v-model="a">
        <span>a:{{a}}</span>
        <span>b:{{b}}</span>
    </div>
    <script>
        new Vue({
            el: '#app',
            data: {
                a: 1,
                c: 3
                // b:0
            },
            methods: {
                /* b:function(){
                    console.log(1);
                    return this.a*2;
                } */
            },
            /* watch:{
                a:{
                    handler:function(){
                        this.b=this.a*2;
                    },
                    immediate:true
                }
            } */
            computed: {
                b: function () {
                    console.log(222)
                    return this.a * 2;
                }
            },
            beforeCreate() {
                console.log(1,this.$el, this.$data)
            },
            created() {
                console.log(2,this.$el, this.$data)
            },
            beforeMount() {
                console.log(4,this.$el, this.$data)
            },
            mounted() {
                console.log(5,this.$el, this.$data)
            }
        })
    </script>
</body>

</html>